package com.supercube.wechat.controller;

import com.supercube.common.utils.R;
import com.supercube.wechat.domain.LeaveMessage;
import com.supercube.wechat.service.LeaveMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 留言控制器
 */
@Controller
@RequestMapping("/miniapp")
public class LeaveMessageController {

    @Autowired
    private LeaveMessageService leaveMessageService;

    /**
     * 提交留言
     * @param message 信息
     * @return 提交状态
     */
    @RequestMapping("/submitMessage")
    @ResponseBody
    public R submitMessage(LeaveMessage message) {
        if (leaveMessageService.submitMessage(message)) {
            return R.ok();
        } else {
            return R.error();
        }
    }
}
